package com.gollum.web.controller.system;

import com.alibaba.fastjson2.JSONObject;
import com.gollum.common.domain.response.RestResponse;
import com.gollum.common.web.controller.BaseController;
import com.gollum.system.domain.request.SysConfigRequest;
import com.gollum.system.domain.request.SysDictDataRequest;
import com.gollum.system.service.SysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统参数配置cotnroller
 *
 * @author Herther
 * @createTime 2022年09月21日 22:02:00
 * @since 1.0.0
 */
@Api(tags = "系统管理-系统参数配置")
@RestController
@RequestMapping("/config")
public class SysConfigController extends BaseController {

    @Autowired
    protected SysConfigService sysConfigService;


    @PostMapping("/list")
    @ApiOperation(value = "分页查询系统参数")
    public RestResponse listPage(@RequestBody JSONObject jsonObject) {
        buildPageQuery(jsonObject);
        SysConfigRequest params = this.toJavaObjectParams(SysConfigRequest.class, jsonObject);
        return RestResponse.success(sysConfigService.listPage(params));
    }


    @GetMapping("/get/{id}")
    @ApiOperation(value="根据ID查询系统参数详情")
    public RestResponse getDetail(@PathVariable("id") Long id){
       return RestResponse.success(sysConfigService.getDetailById(id));
    }


    @PostMapping("/getType")
    @ApiOperation(value = "根据类型查询系统参数")
    public RestResponse getConfig(@RequestBody JSONObject jsonObject) {
        return RestResponse.success(sysConfigService.getConfig(jsonObject));
    }





}
